import Cookies from 'js-cookie'

const tokenKey: string = "token";

// 获取Cookie
export const getCookie = (key: string) => {
  return Cookies.get(key);
}
// 设置Cookie
export const setCookie = (key: string, data: string, day?: number) => {
  return day ? Cookies.set(key, data, { expires: day }) : Cookies.set(key, data);
}
// 删除Cookie
export const delCookie = (key: string) => {
  Cookies.remove(key);
}


// 设置token
export const setToken = (data: string, day?: number) => {
  return day ? Cookies.set(tokenKey, data, { expires: day }) : Cookies.set(tokenKey, data);
}
// 获取token
export const getToken = () => {
  return Cookies.get(tokenKey);
}
// 删除token
export const delToken = () => {
  Cookies.remove(tokenKey);
}
